import Vue from "vue";
import Vuex from "vuex";
import createPersistedState from "vuex-persistedstate";
Vue.use(Vuex);

const store = new Vuex.Store({
  state: {
    token: null,
  },
  getters: {},
  mutations: {
    setToken(state, token) {
      state.token = token;
    },
    removeToken(state) {
      state.token = null;
    },
    getToken: (state) => {
      return state.token;
    },
  },
  actions: {},
  modules: {},
  plugins: [
    createPersistedState(), // 使用插件
  ],
});
export default store;
